<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename='', $stream=TRUE,$paperSet='',$phy_location='') 
{
    require_once("dompdf/dompdf_config.inc.php");
    
    $dompdf = new DOMPDF();
    if($paperSet=='landscape')
	 $dompdf->set_paper('a4', 'landscape');
	else
	  $dompdf->set_paper("a4", "portrait" );
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        //$dompdf->stream($filename.".pdf"); //popup download
		$dompdf->stream($filename.".pdf",array('Attachment'=>0)); //open in browser
    } else {
    	if($phy_location!='')
    	{
    		$pdf = $dompdf->output();
    		file_put_contents($phy_location, $pdf);
    	}
    	else	
        return $dompdf->output();
    }
}
?>